#ifndef __digmania_h__
#define __digmania_h__

#include <GL/gl.h>
#include <SDL/SDL.h>
#include <SDL/SDL_thread.h>

#define CLIENT_CONFIG "client.conf"

/************************************************
 *                  Data types
 ************************************************/

struct client_options 
{
	int window_width;
	int window_height;
	int color_depth;
};
typedef struct client_options client_options_t;

enum client_state 
{
	CS_MAIN_MENU,
	CS_GAME
};
typedef enum client_state client_state_t;

enum block_type
{
	BT_AIR = 0,
	BT_STONE = 1,

	BT_COUNT
};
typedef enum block_type block_type_t;

struct render_context 
{
	int video_flags;
	client_options_t *opts;
	int work;		// loop flag
	SDL_Surface *surface;
	SDL_Thread *worker;
	client_state_t state;
	int is_window_active;
	GLuint textures[BT_COUNT];
};
typedef struct render_context render_context_t;

/************************************************
 *                    Methods
 ************************************************/

// options.c
client_options_t *read_client_config(const char *path);
void destroy_client_options(client_options_t *opts);

// render.c
render_context_t* create_render_context(client_options_t* opts);
void destroy_render_context(render_context_t *context);
void render_loop(render_context_t* context);
void resize_window(int width, int height);
void init_gl_textures(render_context_t *context);

#endif
